<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>axios 响应数据</title>
  </head>
  <body>
    <script src="./js/axios.js"></script>
    <script>
      //配置请求的基准地址
      axios.defaults.baseURL = "http://localhost:3000/";

      //设置axios的拦截器
      axios.interceptors.response.use(
        function (response) {
            console.log('拦截器拦截...');
          return response.data;
        },
        function (error) {
          console.log(error);
        }
      );

      //get请求传入参数
      axios.get("axios-emp/2").then(function (data) {
        //response对象中封装了很多响应的相关的数据
        console.log(data);
      });
    </script>
  </body>
</html>
